package com.lala.controller;

import com.lala.entity.ClientComment;
import com.lala.service.ClientCommentService;
import com.lala.util.ResultJson;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 霍明铭
 * @date 2020/3/27 10:17
 */

@Controller
@RequestMapping("/clientcomment")
public class CommentController {
    @Autowired
    ClientCommentService commentService;

    /**
     *
     * @param clientId
     * @return
     * 评论列表展示
     */
    @GetMapping("/mycomment")
    @ResponseBody
    public ResultJson comment(Integer clientId){
        List<Map> comments= commentService.getComment(clientId);
        return new ResultJson(200,"成功",comments);
    }
    @GetMapping("/all")
    @ResponseBody
    public ResultJson allComment(Integer clientId){
        List<Map> comments= commentService.allComment(clientId);
        return new ResultJson(200,"成功",comments);
    }
    @PostMapping("/save")
    @ResponseBody
    public ResultJson save(ClientComment comment){
       try {
           commentService.save(comment);
           return new ResultJson(200,"",null);
       }catch (Exception e){
           return new ResultJson(500,"",null);
       }

    }


}
